import { exportUrl, getOrderStatusList } from "@/api/checkorder/mesOrderCheckTask"
import { getCurrentWarehouseCode } from "@/api/inbound/mesInTask"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    icon: "el-icon-delete",
    handleName: "deleteBatch", //点击时返回的标识
    isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  },
  {
    name: "指定盘点人",
    type: "primary",
    icon: "el-icon-delete",
    handleName: "designatedStocktaker", //点击时返回的标识
    isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
    disabled: (data) => !data.length || data.some((i) => i.orderStatus != "10") //非未开始状态下禁用
  }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    orderNo: {
      type: "input",
      label: "单据编号"// 单据编号
    },
    goodsCode: {
      type: "input",
      label: "商品编码" // 商品编码
    },
    // warehouseCode: {
    //   type: "select",
    //   prop: {
    //     value: "modelingCode",
    //     text: "modelingName"
    //   },
    //   options: async (data) => {
    //     const res = await getCurrentWarehouseCode()
    //     let list = res.data.result || []
    //     list.forEach((val) => {
    //       val.modelingName = `${val.modelingCode}-${val.modelingName}`
    //     })
    //     return list
    //   },
    //   label: $i18n.t("common.warehouse") // 仓库编码
    // },
    templateName: {
      type: "input",
      label: "模板名称" // 模板名称
    },
    orderStatus: {
      type: "select",
      label: "订单状态", // 订单状态10-未开始 20-盘点中 30-已完成
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getOrderStatusList()
        return list.data.result
      }
    },
    createTime: {
      type: "datetimerange",

      label: $i18n.t("common.createTime"), // 创建时间
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        searchArrKey: ["createTimeMin", "createTimeMax"]
      }
    }
  }
}
// 表单配置
export const dialogFormConfig = {
  span: 24,
  disabled: false,
  labelPosition: "left",
  isShowErrorNotify: true,

  formDesc: {
    personName: {
      type: "input",
      label: $i18n.t("指定人员"),
      layout: 24,
      required: true
    }
  }
}
import {getUserList, getUserListByRoleIdAndFactory} from "@/api/user"
export const userMixin = {
  data() {
    return {
      baseUserDialogVisible: false,
      baseUserSearchDialog: {
        inline: true,
        formDesc: {
          nickName: {
            type: "input",
            layout: 8,
            label: $i18n.t("用户昵称") //"用户昵称"
          }
        }
      },
      baseUserDialogColumn: [
        {
          type: "selection"
        },

        // {
        //   prop: "tenantCode",
        //   label: $i18n.t("users.tenantCode") //"租户编码"
        // },
        {
          prop: "jobNumber",
          label: $i18n.t("工号") //"工号"
        },
        {
          prop: "nickName",
          label: $i18n.t("用户昵称") //"用户昵称"
        },
        {
          prop: "email",
          label: $i18n.t("用户邮箱") //"用户邮箱"
        },
        {
          prop: "mobile",
          label: $i18n.t("手机号码") //"手机号码"
        }
      ],
      getUserListByRoleIdAndFactory
    }

  },
  methods: {
    getSelectBaseUser(data) {
      console.log(data)
      this.$set(this.dialogFormData, "personName", data[0].nickName)
      this.$set(this.dialogFormData, "personCode", data[0].jobNumber)
    },

  }
}
